﻿/*************************************************************************
* Copyright(c) 2020 - Present ShenZhen EscopeTech

* ShenZhen EscopeTech Incoperated CONFIDENTIAL
* ________________________________________________________________________
*
* [2020] - Present ShenZhen EscopeTech Incoperated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of ShenZhen EscopeTech Incoperated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to ShenZhen EscopeTech Incoperated
* and its suppliers and may be covered by P.R.C. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from ShenZhen EscopeTech Incoperated.
*
*************************************************************************/

#ifndef DLogInfoMgr_H
#define DLogInfoMgr_H

#include <QDateTime>
#include <QMutex>
#include <QObject>
#include <atomic>

class DLogInfoMgr
{
public:
    explicit DLogInfoMgr();
    virtual ~DLogInfoMgr() = default;

    void initLogInfo(const QString &strFilePath = "/XALog/XAscope");
    void processMsg(QtMsgType type, const QMessageLogContext &context,
                    const QString &strMsg);

private:
    virtual void deleteFile(const QString &strDir, const int &nCount) final;
    virtual QString genLogFile() final;

private:
    const QDateTime m_dtAppStart = QDateTime::currentDateTime();

    QString m_strFilePath;
    QMutex m_mutex;
    QString m_strFileName;
    uint64_t m_nLogNum = 0;
    int m_nMaxCountLogFile = 30;
};

DLogInfoMgr *getLogInfoMgr();

#endif  // DLogInfoMgr_H
